<template>
  <div>
    <article v-for="item in blogList" style="margin-left: -100px" class="post post-list">

        <div class="post-entry">
            <div class="feature">
                <router-link :to="`/article/${item.detailsId}`" target="_blank">
                    <img :src="item.banner"/>
                </router-link>
            </div>
            <h1 class="entry-title">
                <router-link :to="`/article/${item.detailsId}`" target="_blank"><span v-if="item.isTop" style="color:#ff6d6d;font-weight:600">[置顶] </span>{{item.title}}</router-link>
            </h1>
            <div class="p-time">
                <i class="iconfont iconmeditor-time"></i> {{item.publishTime}}<i v-if="item.isHot" class="iconfont iconfire" style="margin-left: 5px;color: #ff6d6d;"></i>
            </div>
            <p class="summary">{{item.summary}}</p>
            <footer class="entry-footer">
                <div class="post-more">
                  <center>
                    <div style="margin-left: 200px;position: absolute;margin-top: -30px">
                    <v-icon medium
                            color="purple darken-2"
                    > {{icons.mdiAccount}} </v-icon></div>
                    <p style="margin-top: -27px;margin-left: 225px;font-size: 15px;color: #b1b1b1;position: absolute">{{item.author}}</p>
                    <div style="margin-left: 220px;position: absolute;margin-top: -30px">
                    <v-icon
                        medium
                        color="pink"
                    >widgets</v-icon><p style="margin-top: -23px;margin-left: 90px;font-size: 15px;color: #b1b1b1">{{item.sort}}</p></div>
                  </center>
                    <router-link :to="`/article/${item.id}`"><i class="iconfont iconfish-li" style="font-size: 25px;position: absolute;margin-left: -150px;margin-top: -50px"></i></router-link>
                </div>
              <!-- 热度和评论 -->
                <div class="info-meta">
                    <div class="comnum">
                        <span>
                            <i class="iconfont iconcomment"></i>
                            <a>{{item.commentsCount}} 条评论</a>
                        </span>
                    </div>
                    <div class="views">
                        <span><i class="iconfont iconeyes"></i>{{item.viewsCount}} 热度</span>
                    </div>
                </div>
            </footer>

          <hr/>
        </div>
    </article>
  </div>
</template>

<script>
	import Utils from '../assets/js/util.js'
	import underUtil from '../assets/js/underUtil'
	import {
		mdiAccount
	} from '@mdi/js'
    export default {
        name: "post",
        data() {
          return {
						pageSize: 8,
						currentPage: 1,
            total: 0,
						icons: {
							mdiAccount
						},
						blogList: [{
							id: 0,
							isTop: true,
							banner: '',
							isHot: true,
							publishTime: '',
							title: '两年多从入门到入魔,我的Java自学之路',
							summary: 'Java 是一种面向对象编程语言，在Java中你必须将思想转换到万物皆对象中来。',
							viewsCount: 520,
							commentsCount: 99,
							author: '',
              sort: '',
							detailsId: 0
						},
						],
						blogListTemp: [{
							id: 0,
							isTop: true,
							banner: '',
							isHot: true,
							publishTime: '',
							title: '两年多从入门到入魔,我的Java自学之路',
							summary: 'Java 是一种面向对象编程语言，在Java中你必须将思想转换到万物皆对象中来。',
							viewsCount: 520,
							commentsCount: 99,
							author: '',
							sort: '',
							detailsId: 0
						},
						]
					}
        },
        created(){
        	this.getBlogList()
        },
        mounted () {
          var vm = this
          Utils.$on('loadMore', function (pageSize) {
          	if (vm.total - vm.currentPage*vm.pageSize < 1) {
							underUtil.$emit('underline', true)
            }else {
							vm.pageSize = pageSize
							vm.currentPage = vm.currentPage + 1
							vm.getBlogList()
            }
          })
        },
        methods: {
        	getBlogList(){
        		var vm = this
						vm.axios({
							method: 'GET',
							url: 'http://localhost/blog/blog/introduce',
							params: { 'currentPage' : vm.currentPage , 'pageSize' : 8}
						}).then(function (resp) {
							if (resp.data.msg === '执行成功') {
								if (vm.total === 0){
									vm.blogList = resp.data.data.list
								}else {
									vm.blogListTemp = resp.data.data.list
									vm.blogList = vm.blogList.concat(vm.blogListTemp)
								}
								vm.total = resp.data.data.total
							} else {
								vm.$message({
									message: '更新文章失败!',
									type: 'error',
									center: true
								});
							}
						})
          }
        },
        props: {
            post: {
                type: Object
            }
        }
    }
</script>

<style scoped lang="less">
    .post {
        margin: 0 0 4% 0;
        position: relative;
    }

    .post-entry {
        .feature {
            position: absolute;
            margin-top: 10px;

            img {
                width: 100px;
                height: 100px;
                object-fit: cover;
                border-radius: 50%;
                padding: 2px;
                border: 1px solid #DADADA;
                position: relative;
                transition: all 0.2s linear;
                overflow: hidden;
                &:hover {
                    transform: scale(1.1, 1.1);
                    filter: contrast(130%);
                }
            }
        }

        .entry-title {
            font-size: 21px;
            font-weight: 600;
            line-height: 50px;
            margin: 0 0 0 17%;
            position: relative;
            z-index: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            width: 70%;
            color: #737373;

            & a:hover {
                color: #8fd0cc;
            }
        }

        .p-time {
            position: absolute;
            left: 150px;
            top: 88px;
            font-size: 12px;
            color: #989898;
            letter-spacing: 1px;
            font-family: din, 'Hiragino Sans GB', 'Microsoft Yahei', Arial, sans-serif;
            display: flex;
            align-items: center;
        }

        p.summary {
            min-height: 100px;
            width: 600px;
            margin: 0 0 0 17%;
            font-size: 15px;
            color: #6f6f6f;
            letter-spacing: 1px;
            line-height: 30px;
        }

        footer.entry-footer {
            margin: 0 0 0 17%;
            list-style: none;

            .post-more {
                margin-top: 10px;
                text-align: right;
                color: #A0DAD0;

                a:hover {
                    color: #737373;
                }
            }

            .info-meta {
                margin-top: 10px;
                margin-left: -30px;
                font-family: din, 'Hiragino Sans GB', 'Microsoft Yahei', Arial, sans-serif;
                position: absolute;
                top: 20px;
                opacity: 0;
                padding-top: 8px;
                border-top: 1px solid #ddd;
                -webkit-transform: translate3d(-150px, 0, 0);
                transform: translate3d(-150px, 0, 0);
                visibility: hidden;
                transition: .7s all ease;
                -webkit-transition: .6s all ease;
                -moz-transition: .6s all linear;
                -o-transition: .6s all ease;
                -ms-transition: .6s all ease;

                span, a {
                    color: #B3B3B3;
                    font-size: 12px;
                }

                i {
                    margin-top: 3px;
                    margin-right: 10px;
                    float: left
                }
            }

            .comnum {
                float: left;
            }
        }

    }

    .post-entry:hover footer.entry-footer .info-meta {
        -webkit-transform: translate3d(-230px, 0, 0);
        transform: translate3d(-230px, 0, 0);
        opacity: 1;
        visibility: visible;
    }

    .post hr {
        width: 30%;
        height: 1px;
        margin: 0 auto;
        border: 0;
        background: #EFEFEF;
    }

    /*******/
    @media (max-width: 1060px) {
        .info-meta{
            display: none;
        }
    }
    @media (max-width: 800px) {
        .post-entry {
            .feature img {
                width: 50px;
                height: 50px;
            }
            .entry-title{
                font-size: 16px;
                line-height: 30px;
                margin: 0 0 0 65px;
            }
            .p-time {
                position: relative;
                margin: -15px 0 0 65px;
            }
            p.summary {
                margin: 20px 0 0 65px;
                font-size: 14px;
                height: 30px;
                overflow: hidden;
            }
            .post-more{
                display: none;
            }
        }
        .post-list hr {
            margin-top: 20px;
        }
    }

    /******/
</style>
